package com.demo.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.web.client.RestTemplate;

/**
 * Created by Lucicol on 2018/2/8.
 */
@RestController
public class GetToken {

    @GetMapping("/ac-token")
    public void getAccessToken() {
//        System.out.println("111111");
        String access_token = null;
        String grant_type = "client_credential";
        String AppId= "wx604b54a21bd895b9";
        String secret= "aff4c828a67ccf4a1c9f421ea117f8a1";
        String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type="+grant_type+"&appid="+AppId+"&secret="+secret;
//        String url = "http://baidu.com";

        RestTemplate restTemplate = new RestTemplate();
        String response = restTemplate.getForObject(url, String.class);
        System.out.println(response);
    }
}
